package com.ccb.lms.action;

import java.sql.SQLException;

import com.ccb.lms.facade.FacadeService;
import com.ccb.lms.model.Book;
import java.util.List;

@SuppressWarnings("serial")
public class BookAction extends AbstractAction {

	private FacadeService facadeService;
	private Book book;
	private int bookNO;
	private String copyBarCode;
	private String readerSearch;
	private String selectType;

	private List<Book> list;

	@Override
	public String execute() throws Exception {

		return super.execute();
	}

	public String getBookbyNO() {

		try {
			book = facadeService.getBookService().getBookByNO(bookNO);
		} catch (SQLException e) {
			e.printStackTrace();
			return ERROR;
		}
		return SUCCESS;
	}

	public String getBookBySearch() {
		try {
			if (selectType.equals("题名"))
				list = facadeService.getBookService().getBookByName(
						readerSearch);
			else
				list = facadeService.getBookService().getBookByAuthor(
						readerSearch);
		} catch (SQLException e) {
			e.printStackTrace();
			return ERROR;
		}
		return SUCCESS;
	}

	public FacadeService getFacadeService() {
		return facadeService;
	}

	public void setFacadeService(FacadeService facadeService) {
		this.facadeService = facadeService;
	}

	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	public int getBookNO() {
		return bookNO;
	}

	public void setBookNO(int bookNO) {
		this.bookNO = bookNO;
	}

	public String getCopyBarCode() {
		return copyBarCode;
	}

	public void setCopyBarCode(String copyBarCode) {
		this.copyBarCode = copyBarCode;
	}

	public String getSelectType() {
		return selectType;
	}

	public void setSelectType(String selectType) {
		this.selectType = selectType;
	}

	public String getReaderSearch() {
		return readerSearch;
	}

	public void setReaderSearch(String readerSearch) {
		this.readerSearch = readerSearch;
	}

	public List<Book> getList() {
		return list;
	}

	public void setList(List<Book> list) {
		this.list = list;
	}

}
